﻿/*
*┌─────────────────────────────────┐
*│　描   述：钱数的总管理
*│　类   名：MoneyManager.cs 
*│　创  建  人：DD
*│　创建时间：
*│　Copyright(C) 2020 by DD
*└─────────────────────────────────┘
*┌─────────────────────────────────┐
*│　修  改  人：
*│　创建日期：
*└─────────────────────────────────┘
*/

using System.Collections;
using System.Collections.Generic;

using UnityEngine;
using UnityEngine.UI;

public class MoneyManager : SingleBase<MoneyManager>
{
    //private static MoneyManager _instance;
    //public static MoneyManager Instance
    //{
    //    get
    //    {
    //        if ( _instance == null )
    //            _instance = new MoneyManager ();
    //        return _instance;
    //    }
    //}



    public Text _showMoney;

    private void Start( )
    {
        _showMoney.text = PlayerPrefs.GetFloat ( "Money" ).ToString ( "f2" );
    }
    public void AddMoney(float count)
    {
        Debug.Log (string.Format("加了{0}钱",count));
        float tempValue = PlayerPrefs.GetFloat ( "Money" )+count;
        Debug.Log ( "总钱数是" + tempValue );
        PlayerPrefs.SetFloat ( "Money" , tempValue );
    }

    private void Update( )
    {
        _showMoney.text = PlayerPrefs.GetFloat ( "Money" ).ToString ( "f2" );
    }

}
